package myky.com.doctorapp.api.schedulers;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import java.util.concurrent.TimeUnit;

import io.reactivex.FlowableTransformer;
import io.reactivex.ObservableTransformer;
import io.reactivex.Scheduler;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

/**
 * Created by Zaifeng on 2018/2/28.
 * 线程切换
 */
public class SchedulerHelper {

    @NonNull
    public static <T> ObservableTransformer<T, T> applySchedulers() {
        return observable -> observable.delay(500, TimeUnit.MILLISECONDS).subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }@NonNull
    public static <T> FlowableTransformer<T, T> IO() {
        return observable -> observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }
}
